import json
from datetime import datetime
from urllib import parse
from flask import Flask, Response
import requests
from flask import request
from retrying import retry


# user = parse.quote_plus("admin")
# passwd = parse.quote_plus("Zhcx@2023#MonDb")
# modb1 = MongoDBLink(
#     uri=f'mongodb://{user}:{passwd}@116.205.233.77:8807/?authSource=admin',
#     dbname='walmart_api_table', coll_name='web_logs_aliexpress_all')


class CGVMAgent():

    @retry(stop_max_attempt_number=5, wait_fixed=2000)
    @staticmethod
    def common_handler(method, url, data):
        """
        公共处理
        :return:
        """
        resp = requests.post(url, json=data)
        if resp.status_code != 200:
            raise
        return resp.status_code,resp.json()
